Jerry's Blogs

Monday, November 19, 2007

On Using Rails Magic Outside of Ruby

I started out initially trying to just connect to Postgresql using the postgres driver. Unfortunately, this didn't work because my postgres was hanging. I was skeptical because different sites hosted different APIs for using the driver, but the official site gave the wrong ones (Oh! Java, how I miss thee).

This led to be reach into higher and more tested abstractions. I finally came across a hideously formatted wiki page that had many different peoples' attempts to use Rails black magic in normal Ruby. My favorite one, the one of least effort, was simply adding:

require File.dirname(__FILE__) + "/../config/environment"

or whatever the relative path the config/environment is. This will 'require' all the magical bits: models, active-record, rubygems, lib, and plugins. The other organizational bit I learned was to add a 'bin' directory at the top level for plain scripts that need be executed by cron.

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home